package org.test.portlet;

import java.io.IOException;

import javax.portlet.ActionRequest;
import javax.portlet.ActionResponse;
import javax.portlet.GenericPortlet;
import javax.portlet.PortletException;
import javax.portlet.ProcessAction;
import javax.portlet.RenderMode;
import javax.portlet.RenderRequest;
import javax.portlet.RenderResponse;
import javax.xml.namespace.QName;

public class NamePortlet extends GenericPortlet {
	private static final String JSP_FILE = "/WEB-INF/jsp/viewName.jsp";

	@RenderMode(name = "VIEW")
	public void view(RenderRequest request, RenderResponse response)
			throws PortletException, IOException {
		getPortletContext().getRequestDispatcher(JSP_FILE).include(request,
				response);
	}

	@ProcessAction(name = "nameAction")
	@Override
	public void processAction(ActionRequest request, ActionResponse response)
			throws PortletException, IOException {
		QName eventName = new QName("http://test.portlet.org", "name");
		String name = request.getParameter("name");
		response.setEvent(eventName, name);
	}
}
